//
//  XJNetWorkingManager.m
//  JingShiDemo
//
//  Created by XDD on 16/2/23.
//  Copyright © 2016年 XDD. All rights reserved.
//

#import "XJNetWorkingManager.h"
#import "AFHTTPSessionManager.h"

@implementation XJNetWorkingManager

+ (NSURLSessionDataTask *)postWithUrl:(NSString *)url params:(NSDictionary *)params successHandler:(SuccessBlock)success failureHandler:(FailureBlock)failure{
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
    
    NSURLSessionDataTask *dataTask = [manager POST:[RootServer stringByAppendingString:url]    parameters:params success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {
        if (success) {
            success(responseObject);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (failure) {
            NSLog(@"网络请求失败 = %@",error);
            failure(error);
        }
    }];
    // 参数要写userId
    return dataTask;
}

@end
